package com.liangzhong.proxy.activity
{
	import com.global.GlobalDef;
	import com.liangzhong.commandconst.activity.CMD_Activity;
	import com.liangzhong.commandconst.commandType.MainCommandType;
	import com.liangzhong.commandconst.pub.CMD_Public;
	import com.liangzhong.constants.ApplicationConstants;
	import com.liangzhong.constants.HttpRequestConst;
	import com.liangzhong.errortip.ErrorTips;
	import com.liangzhong.events.ActivityEvent;
	import com.liangzhong.events.AppEventDispatcher;
	import com.liangzhong.events.NotifierEvent;
	import com.liangzhong.global.CMD_Head;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.goods.vo.GoodsVo;
	import com.liangzhong.proxy.BaseProxy;
	import com.liangzhong.proxy.ProxyUtils;
	import com.liangzhong.proxyconstant.activity.ActivityConst;
	import com.socket.clientsocket.IClientSocket;
	
	import flash.events.Event;
	import flash.net.URLVariables;
	import flash.utils.ByteArray;
	
	import lz.controls.Alert;
	
	/**
	 *活动 
	 * @author lake
	 * 
	 */	
	public class ActivityProxy extends BaseProxy
	{
		public static const ProxyName :String = "ActivityProxy";
		
		public function ActivityProxy(proxyName:String=ProxyName, data:Object=null)
		{
			super(proxyName, data);
		}
		override public function onSocketRead(mainCmdID:uint, subCmdID:uint, buffer:ByteArray, dataSize:int, clientSocket:IClientSocket):Boolean
		{
			switch(mainCmdID)
			{
				case MainCommandType.TASK:
					return onDeal(subCmdID,buffer,dataSize,clientSocket);
				case MainCommandType.VIP:
					return onVip(subCmdID,buffer,dataSize,clientSocket);
				case CMD_Public.MAIN:
					return onDealPub(subCmdID,buffer,dataSize,clientSocket);
			}
			return false;
		}
		private function onVip(subCmdID:uint, buffer:ByteArray, dataSize:int, clientSocket:IClientSocket):Boolean
		{
			switch(subCmdID)
			{
				case CMD_Activity.VIP_CHANGE_LV://vip等级改变
					var lv:int = buffer.readInt();
					var topca:int = buffer.readInt();
					AppData.getInstance().clubDatamanager.clubInfo.cashpoint_vip += topca;
					this.sendNotification(ActivityConst.VIP_LV_CHANGE,{lv:lv});
					var vipLv:int = AppData.getInstance().clubDatamanager.clubInfo.VIP;
					if(lv > vipLv)
					{
						AppData.getInstance().clubDatamanager.clubInfo.VIP =  lv;
						//						AppData.getInstance().clubDatamanager.clubInfo.vip_reward_every = 1;
					}
					
					AppEventDispatcher.getInstance().dispatchEvent(new Event(NotifierEvent.BASE_INFO_CHANGE));
					return true;
				case CMD_Activity.THE_FIRST_CHARGE:
					AppData.getInstance().clubDatamanager.clubInfo.firstpay = 1;
					this.sendNotification(ActivityConst.FINISH_FIRST_CHARGE);
					break;
			}
			return false;
		}
		/**
		 * 处理
		 * 任务 30; 
		 * @param subCmdID
		 * @param buffer
		 * @param dataSize
		 * @param clientSocket
		 * @return 
		 * 
		 */
		private function onDeal(subCmdID:uint, buffer:ByteArray, dataSize:int, clientSocket:IClientSocket):Boolean
		{
			var results:int;
			var retcode 	:int;
			switch(subCmdID)
			{
				case CMD_Activity.LIVENESS_AWARD:
					getLivenessAward(buffer);
					return true;;
				case CMD_Activity.MAKESTAR_AWARD:
					getmakestarAward(buffer);
					return true;
				case CMD_Activity.LEVEL_AWARD:
					getLevelAward(buffer);
					return true;;
				case CMD_Activity.VIP_DAILY_AWARD:
					getVipDailyAward(buffer);
					return true;
				case CMD_Activity.VIP_AWARD:
					getVipLvAward(buffer);
					return true;
				case CMD_Activity.TOPUPFEEDBADK:
					getTopupfeedbadkWard(buffer);
					return true;
				case CMD_Activity.CHRISTMAS_AWARD://圣诞 雪球兑换道具 
				{
					retcode = buffer.readInt();
					if(retcode == 0)
					{
						var type 		:int = buffer.readByte();//兑换类型
						var snowballs 	:int = buffer.readInt();//雪球数量
						var pid			:int = buffer.readInt();//道具id
						var ntype		:int = buffer.readByte();//道具类型
						AppData.getInstance().activityDatemanager.christmasVo.setSnowballs(snowballs);
						var goods :GoodsVo = AppData.getInstance().goodsManager.getGoodsByTypeAndId(ntype,pid);
						if(goods)
						{
							//Alert.showErrorTip("获得了" + goods.name + "");
						}
						if(type < 6)
						{
							Alert.showErrorTip("兑换成功");
						}
						else
						{
							AppData.getInstance().activityDatemanager.christmasVo.dispatchEvent(new ActivityEvent(ActivityEvent.ACTIVITY_CHRISTMAS_AWARD_RES,{type:type,pid:pid,ntype:ntype}));
						}
					}
					else
					{
						Alert.showErrorTip(ErrorTips.instance.getCErrorTip(retcode) + "");
					}
					return true;
				}
				case CMD_Activity.FESTIVAL_VIP:
					getFestivalVip(buffer);
					return true;
				case CMD_Activity.OPENSERVE_AWARD:
					
					getOpenServeAward(buffer);
					return true;
				case CMD_Activity.MATCHWELFARE_AWARD:
					getMatchWelfareAward(buffer);
					return true;
				case CMD_Activity.ACCUMULATECONSUMPTIONAWARD:
					getAccumulateConsumptionAward(buffer);
					return true;
				case CMD_Activity.ONLINE_AWARD:
					getOnlineAward(buffer);
					return true;
			}
			return false;
		}
		/**
		 * 处理
		 * 公共 40; 
		 * @param subCmdID
		 * @param buffer
		 * @param dataSize
		 * @param clientSocket
		 * @return 
		 * 
		 */
		private function onDealPub(subCmdID:uint, 
								   buffer:ByteArray, 
								   dataSize:int, 
								   clientSocket:IClientSocket):Boolean
		{
			var retcode 	:int;
			switch(subCmdID)
			{
				case CMD_Public.SUB_ADD_SNOWBALL_NUM://点券增加雪球数量
				{
					retcode = buffer.readInt();
					if(retcode == 0)
					{
						var snowballs :int = buffer.readInt();
						AppData.getInstance().activityDatemanager.christmasVo.setSnowballs(snowballs);
					}
					else
					{
						Alert.showErrorTip(ErrorTips.instance.getCErrorTip(retcode) + "");
					}
					return true;
				}
				case CMD_Activity.TIMELIMIT_BUYGOODS:
				{
					getTimeLimitBuyGoods(buffer);
					return true;
				}
			}
			return false;
		}
		//		private function ondealpublic
		/**
		 *请求领取活跃度奖励 
		 * @param $obj
		 * 
		 */
		public function requestLivenessaward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.LIVENESS_AWARD);
			var id:int = $obj.id;
			sendBuf.writeByte(id);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 *返回活跃度奖励 
		 * 
		 */
		private function getLivenessAward(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				this.sendNotification(ActivityConst.GET_LIVENESS_AWARD,{status:true});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_LIVENESS_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 *请求活跃度信息 
		 * 
		 */
		public function requestLivenessInfo():void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_LIVENESS;
			ProxyUtils.instance.webClient(getLivenessInfo,variables,false);
		}
		/**
		 *返回活跃度信息 
		 * 
		 */
		private function getLivenessInfo($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				this.sendNotification(ActivityConst.GET_LIVENESS_INFO,obj.vitality);
			}else
			{
				Alert.showErrorTip(ErrorTips.instance.getErrorTip(obj.retcode));
			}
		}
		/**
		 *请求领取活跃度奖励 
		 * @param $obj
		 * 
		 */
		public function requestmakestaraward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.MAKESTAR_AWARD);
			var id:int = $obj.id;
			sendBuf.writeByte(id);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 *返回活跃度奖励 
		 * 
		 */
		private function getmakestarAward(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				this.sendNotification(ActivityConst.GET_MAKESTAR_AWARD,{status:true});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_MAKESTAR_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 *请求活跃度信息 
		 * 
		 */
		public function requestmakestarInfo():void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_MAKESTAR;
			ProxyUtils.instance.webClient(getmakestarInfo,variables,false);
		}
		/**
		 *返回活跃度信息 
		 * 
		 */
		private function getmakestarInfo($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				this.sendNotification(ActivityConst.GET_MAKESTAR_INFO,obj.seven);
			}else
			{
				Alert.showErrorTip(ErrorTips.instance.getErrorTip(obj.retcode));
			}
		}
		/**
		 *领取冲级奖励 
		 * @param $obj
		 * 
		 */
		public function requestlevelaward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.LEVEL_AWARD);
			var id:int = $obj.id;
			sendBuf.writeByte(id);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		private function getLevelAward(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				this.sendNotification(ActivityConst.GET_LEVEL_AWARD,{status:true,id:buffer.readByte()});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_LEVEL_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		
		/**
		 *请求冲级信息 
		 * 
		 */
		public function requestLevelInfo():void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_LEVEN;
			ProxyUtils.instance.webClient(getLevelInfo,variables,false);
		}
		private function getLevelInfo($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				AppData.getInstance().activityDatemanager.rushLevelObj = obj.rushlevel;
				this.sendNotification(ActivityConst.GET_LEVEL_INFO,obj.rushlevel);
			}else
			{
				Alert.showErrorTip(ErrorTips.instance.getErrorTip(obj.retcode));
			}
		}
		/**
		 *请求vip等级奖励 
		 * 
		 */
		public function requestVipLvAward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.VIP_AWARD);
			var id:int = $obj.id;
			sendBuf.writeByte(id);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 *返回vip等级奖励 
		 * @param buffer
		 * 
		 */
		private function getVipLvAward(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				this.sendNotification(ActivityConst.GET_VIP_LV_AWARD,{status:true,id:buffer.readByte()});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_VIP_LV_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 *请求vip每日奖励 
		 * 
		 */
		public function requestVipDailyAward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size ,MainCommandType.TASK,CMD_Activity.VIP_DAILY_AWARD);
			var id:int = $obj.id;
			//			sendBuf.writeByte(id);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 *返回vip每日奖励 
		 * @param buffer
		 * 
		 */
		private function getVipDailyAward(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				AppData.getInstance().clubDatamanager.clubInfo.vip_reward_every = 1;
				this.sendNotification(ActivityConst.GET_VIP_DAILY_AWARD,{status:true});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_VIP_DAILY_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 *请求vip信息 
		 * 
		 */
		public function requestVipInfo():void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_VIP;
			ProxyUtils.instance.webClient(getVipInfo,variables,false);
		}
		/**
		 *返回vip信息 
		 * @param $data
		 * 
		 */
		private function getVipInfo($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				this.sendNotification(ActivityConst.GET_VIP_INFO,obj.rushlevel);
			}else
			{
				Alert.showErrorTip(ErrorTips.instance.getErrorTip(obj.retcode));
			}
		}
		/**
		 *获取 黄钻信息
		 */		
		public function getQzoneInfo():void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_QZONE_AWARD_INFO;
			ProxyUtils.instance.webClient(getQzoneInfoRes,variables,false);
		}
		/**
		 *返回黄钻信息
		 * @param $data
		 * 
		 */
		private function getQzoneInfoRes($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				AppData.getInstance().activityDatemanager.qzoneVo.parse(obj);
			}
		}
		/**
		 * 取充值回馈信息 
		 * 
		 */
		public function requesttopupfeedbackinfo():void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_TOPUPFEEDBACKINFO;
			ProxyUtils.instance.webClient(gettopupfeedbackinfo,variables,false);
		}
		/**
		 * 返回充值回馈信息 
		 * @param $data
		 * 
		 */
		private function gettopupfeedbackinfo($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				
				this.sendNotification(ActivityConst.GET_TOPUPFEEDBACK_INFO,obj.active);
			}
		}
		
		/**
		 *请求领取充值回馈奖励 
		 * 
		 */
		public function requestTopupfeedbadkWard($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.TOPUPFEEDBADK);
			var id:int = $obj.id;
			sendBuf.writeByte(id);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 *返回领取充值回馈奖励 
		 * @param buffer
		 * 
		 */
		private function getTopupfeedbadkWard(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				var id:int = buffer.readByte();
				//				trace("领取的ID："+id);
				this.sendNotification(ActivityConst.GET_TOPUPFEEDBACK_AWARD,{status:true,id:id});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_TOPUPFEEDBACK_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 *获取 圣诞活动信息
		 */		
		public function getChristmasInfo():void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_CHRISTMAS_INFO;
			ProxyUtils.instance.webClient(getChristmasInfoRes,variables,false);
		}
		/**
		 *返回 圣诞活动信息
		 * @param $data
		 * 
		 */		
		private function getChristmasInfoRes($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				AppData.getInstance().activityDatemanager.christmasVo.parse(obj);
			}
		}
		/**
		 *点券增加雪球数量 
		 * @param $data
		 */		
		public function addSnowBallNum(param:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size,CMD_Public.MAIN,CMD_Public.SUB_ADD_SNOWBALL_NUM);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 *圣诞 雪球兑换道具  
		 * @param param {type:1}
		 * 兑换类型：
		 1,5个雪球
		 2,10个雪球
		 3,20个雪球
		 4,50个雪球
		 5,100个雪球
		 6,小宝箱
		 7,金宝箱
		 8,钻石宝箱
		 */		
		public function christmasAward(param:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.CHRISTMAS_AWARD);
			sendBuf.writeByte(int(param.type));
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 * 节日活动vip奖励
		 * @param $obj
		 * 
		 */
		public function reqeustFestivalVip($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size,MainCommandType.TASK,CMD_Activity.FESTIVAL_VIP);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		/**
		 *领取返回节日vip奖励 
		 * @param buffer
		 * 
		 */
		private function getFestivalVip(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				this.sendNotification(ActivityConst.GETACTIVITY_FESTIVAL_VIP,{status:true});
			}
			else
			{
				this.sendNotification(ActivityConst.GETACTIVITY_FESTIVAL_VIP,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 *请求节日活动vip信息 
		 * @param $obj
		 * 
		 */
		public function reqeustFestivalVipInfo($obj:Object):void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACTIVITY_FESTIVAL_INFO;
			ProxyUtils.instance.webClient(getFestivalVipInfo,variables,false);
		}
		/**
		 *返回节日活动vip信息 
		 * @param $date
		 * 
		 */
		private function getFestivalVipInfo($date:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($date,ActivityProxy);
			if(obj.retcode == 0)
			{
				this.sendNotification(ActivityConst.GET_ACTIVITY_FESTIVAL_VIP_INFO,{status:true,holiday:obj.holiday});
			}else
			{
				this.sendNotification(ActivityConst.GET_ACTIVITY_FESTIVAL_VIP_INFO,{status:false});
			}
		}
		
		
		/***********	开服活动		******************/
		
		/**
		 *请求开服活动信息 
		 * @param $obj
		 * 
		 */
		public function requestOpenServeInfo($obj:Object):void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.OPENSERVE_INFO;
			ProxyUtils.instance.webClient(getOpenServeInfo,variables,false);
		}
		/**
		 *返回开服活动信息 
		 * @param $date
		 * 
		 */
		private function getOpenServeInfo($date:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($date,ActivityProxy);
			if(obj.retcode == 0)
			{
				this.sendNotification(ActivityConst.GET_ACTIVITY_OPENSERVE_INFO,obj.status);
			}
			
		}
		/**
		 *请求领取开服奖励 
		 * @param $obj
		 * 
		 */
		public function requestOpenServeAward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.OPENSERVE_AWARD);
			
			sendBuf.writeByte($obj.type);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		
		/**
		 *返回领取开服奖励 
		 * 
		 */
		private function getOpenServeAward(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				this.sendNotification(ActivityConst.GET_OPENSERVE_AWARD,{status:true});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_OPENSERVE_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		
		
		
		/***********	充值返利活动		******************/
		
		/**
		 *请求充值返利活动信息 
		 * @param $obj
		 * 
		 */
		public function requestTopupRebateInfo($obj:Object):void
		{
			
		}
		/**
		 *返回充值返利活动信息 
		 * @param $date
		 * 
		 */
		private function getTopupRebateInfo($date:Object):void
		{
			
		}
		/**
		 *请求领取充值返利奖励 
		 * @param $obj
		 * 
		 */
		public function requestTopupRebateAward($obj:Object):void
		{
			//			var sendBuf :ByteArray = 
			//				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.OPENSERVE_AWARD);
			//			
			//			sendBuf.writeByte($obj.type);
			//			sendBuf.position = 0;
			//			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		
		/**
		 *返回领取充值返利奖励 
		 * 
		 */
		private function getTopupRebateAward(buffer:ByteArray):void
		{
			
			//			var nReturn:int = buffer.readInt();
			//			if(nReturn ==0)
			//			{
			//				Alert.showErrorTip("领取成功");
			//				this.sendNotification(ActivityConst.GET_OPENSERVE_AWARD,{status:true});
			//			}
			//			else
			//			{
			//				this.sendNotification(ActivityConst.GET_OPENSERVE_AWARD,{status:false});
			//				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			//			}
		}
		
		
		
		
		/***********	比赛福利		******************/
		
		/**
		 *请求比赛福利活动信息 
		 * @param $obj
		 * 
		 */
		public function requestMatchWelfareInfo($obj:Object):void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.MATCHWELFARE_INFO;
			ProxyUtils.instance.webClient(getMatchWelfareInfo,variables,false);
		}
		/**
		 *返回比赛福利活动信息 
		 * @param $date
		 * 
		 */
		private function getMatchWelfareInfo($date:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($date,ActivityProxy);
			if(obj.retcode == 0)
			{
				this.sendNotification(ActivityConst.GET_MATCHWELFARE_INFO,obj.matchReward);
			}
		}
		/**
		 *请求领取比赛福利奖励 
		 * @param $obj
		 * 
		 */
		public function requestMatchWelfareAward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.MATCHWELFARE_AWARD);
			
			sendBuf.writeByte($obj.type);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		
		/**
		 *返回领取比赛福利奖励 
		 * 
		 */
		private function getMatchWelfareAward(buffer:ByteArray):void
		{
			
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				this.sendNotification(ActivityConst.GET_MATCHWELFARE_AWARD,{status:true,type:buffer.readByte()});
				Alert.showErrorTip("领取成功");
			}
			else
			{
				this.sendNotification(ActivityConst.GET_MATCHWELFARE_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		
		
		
		/***********	累积消费		******************/
		
		/**
		 *请求比赛福利活动信息 
		 * @param $obj
		 * 
		 */
		public function requestAccumulateConsumptionInfo($obj:Object):void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.ACCUMULATECONSUMPTIONINFO;
			ProxyUtils.instance.webClient(getAccumulateConsumptionInfo,variables,false);
		}
		/**
		 *返回比赛福利活动信息 
		 * @param $date
		 * 
		 */
		private function getAccumulateConsumptionInfo($date:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($date,ActivityProxy);
			if(obj.retcode == 0)
			{
				this.sendNotification(ActivityConst.GET_ACCUMULATECONSUMPTION_INFO,obj.status);
			}	
		}
		/**
		 *请求领取比赛福利奖励 
		 * @param $obj
		 * 
		 */
		public function requestAccumulateConsumptionAward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 1,MainCommandType.TASK,CMD_Activity.ACCUMULATECONSUMPTIONAWARD);
			
			sendBuf.writeByte($obj.type);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		
		/**
		 *返回领取比赛福利奖励 
		 * 
		 */
		private function getAccumulateConsumptionAward(buffer:ByteArray):void
		{
			
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				this.sendNotification(ActivityConst.GET_ACCUMULATECONSUMPTION_AWARD,{status:true,type:buffer.readByte()});
			}
			else
			{
				this.sendNotification(ActivityConst.GET_ACCUMULATECONSUMPTION_AWARD,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 * 激活码兑换奖励 
		 * @param param
		 * 
		 */		
		public function cdkeyGetAward(param:Object):void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.CDKEY_GET_AWARD;
			variables.ackey = param.cdkey;
			variables.platform = 3//GlobalDef.Platform_Code;
			ProxyUtils.instance.webClient(cdkeyGetAwardRes,variables,false);
		}
		/**
		 *激活码兑换奖励 返回
		 * @param $data
		 * 
		 */
		private function cdkeyGetAwardRes($data:Object):void
		{
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj && obj.retcode == 0)
			{
				Alert.showErrorTip("兑换成功,请到邮箱领取");
				this.sendNotification(ApplicationConstants.MAIL_GET_LIST);
			}else if(obj)
			{
				var retcode : int = int(obj.retcode);
				if(retcode == -8002)
				{
					Alert.showErrorTip("已经领取过该类型奖励");
				}
				else
				{
					Alert.showErrorTip("激活码无效");
				}
			}
			this.sendNotification(ActivityConst.CDKEY_GET_AWARD_RES,obj);
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/**
		 *请求购买物品
		 * @param $obj
		 * 
		 */
		public function requestTimeLimitBuyGoods($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size + 7,MainCommandType.PUBLICCOMMANDTYPE,CMD_Activity.TIMELIMIT_BUYGOODS);
			sendBuf.writeInt($obj.id);
			sendBuf.writeByte($obj.type);
			sendBuf.writeShort($obj.num);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		
		/**
		 *返回购买
		 * 
		 */
		private function getTimeLimitBuyGoods(buffer:ByteArray):void
		{
			
			var nReturn:int = buffer.readInt();
			if(nReturn ==0)
			{
				Alert.showErrorTip("购买成功");
			}
			else
			{
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		/**
		 * 请求打折信息
		 * @param param
		 * 
		 */		
		public function requestTimeLinitInfo(param:Object):void
		{
			var variables:URLVariables = ProxyUtils.instance.getUrlVariables();
			variables.method = HttpRequestConst.TIMELIMIT_INFO;
			ProxyUtils.instance.webClient(getTimeLinitInfo,variables,false);
		}
		/**
		 *返回打折信息
		 * @param $data
		 * 
		 */
		private function getTimeLinitInfo($data:Object):void
		{
			
			var obj:Object = ProxyUtils.instance.analysisHttpData($data,ActivityProxy);
			if(obj.retcode == 0)
			{
				AppData.getInstance().activityDatemanager.getActivityTimeLimitInfo(obj.prop);
				this.sendNotification(ActivityConst.GET_TIMELIMIT_INFO);
			}else
			{
			}
		}
		
		/**
		 *请求在线奖励 
		 * @param $obj
		 * 
		 */
		public function requestOnlineAward($obj:Object):void
		{
			var sendBuf :ByteArray = 
				CMD_Head.getHeadByteArrayBuff(CMD_Head.Size ,MainCommandType.TASK,CMD_Activity.ONLINE_AWARD);
			sendBuf.position = 0;
			clientSocket.sendData(sendBuf,sendBuf.bytesAvailable);
		}
		
		/**
		 *返回在线奖励 
		 * 
		 */
		private function getOnlineAward(buffer:ByteArray):void
		{
			var nReturn:int = buffer.readInt();
			var type:int;
			var time:int;
			if(nReturn ==0)
			{
				Alert.showErrorTip("领取成功");
				type = buffer.readByte();
				time = buffer.readInt();
				AppData.getInstance().activityDatemanager.onLineInfo(type,time);
				this.sendNotification(ActivityConst.GET_ONLINE_INFO,{status:true});
			}
			else
			{
				type = buffer.readByte();
				time = buffer.readInt();
				AppData.getInstance().activityDatemanager.onLineInfo(type,time);
				this.sendNotification(ActivityConst.GET_ONLINE_INFO,{status:false});
				Alert.showErrorTip(ErrorTips.instance.getCErrorTip(nReturn));
			}
		}
		
	}
}